Fix mem clobber in tmpro.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 8 Aug 2013 01:00:10 +0000 (01:00 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 8 Aug 2013 01:00:10 +0000 (01:00 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4520 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/tmpro.cc

index 0cc89866ef06af6a43c26badcde3a5a56b7fa467..1f0089519132cf31c16a3813ca7d3daca6493f73 100644 (file)
@@ -212,12 +212,11 @@ tmpro_waypt_pr(const waypoint * wpt)
   /* Number of characters */
   /*  25    6      80         8    8      8         8       8    4       4       128      */
 
-  const char *l;
+  const char *l = NULL;
   if (wpt->HasUrlLink()) {
+    // Yes, it's lame to allocate/copy here.
     UrlLink link = wpt->GetUrlLink();
-    l  = link.url_.toUtf8().data();
-  } else {
-    l = "";
+    l  = xstrdup(link.url_.toUtf8().data());
   }
   gbfprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n",
             shortname,
@@ -237,6 +236,9 @@ tmpro_waypt_pr(const waypoint * wpt)
   if (shortname) {
     xfree(shortname);
   }
+  if (l) {
+    xfree(l);
+  }
 }
 
 static void